<%@ page contentType="text/html; charset=UTF-8" language="java"%>
<%@ page import="com.hzqy.commons.utils.ConstantUtils" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>内容修改</title>
<link rel="stylesheet" type="text/css"	href="../static/js/themes/defalut.css">
<link rel="stylesheet" type="text/css"	href="../static/js/themes/public.css">
<link rel="stylesheet" type="text/css"	href="../static/js/themes/ddspstyle.css">
<link rel="stylesheet" type="text/css"	href="../static/js/themes/default/easyui.css">
<link rel="stylesheet" type="text/css"	href="../static/js/themes/icon.css">
<link rel="stylesheet" type="text/css"	href="../static/js/WdatePicker/skin/WdatePicker.css">
<script type="text/javascript" src="../static/js/jquery.min.js"></script>
<script type="text/javascript" src="../static/js/jquery.easyui.min.js"></script>
<script type="text/javascript"	src="../static/js/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="../static/js/jquery.validate.js"></script>
<script type="text/javascript" src="../static/js/index.js"></script>
<script type="text/javascript" src="../static/js/WdatePicker/WdatePicker.js"></script>
	<script type="text/javascript" charset="utf-8" src="../static/js/Base64.js"></script>
	<script type="text/javascript" charset="utf-8" src="../static/js/beforeData.js"></script>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<%
	String catPara =request.getParameter("f_ccc_catalogid");
	String conPara =request.getParameter("f_ccc_contentid");
	int f_ccc_catalogid = 0;
	int f_ccc_contentid = 0;
	if(catPara != null)
		f_ccc_catalogid = Integer.valueOf(catPara);
	if(conPara != null)
		f_ccc_contentid = Integer.valueOf(conPara);
	String []nonceObj=ConstantUtils.getNonceObject();
%>
<script type="text/javascript">
	$(function() {
		$("#f_ccc_contentid").val(<%=f_ccc_contentid%>);
		$("#f_ccc_catalogid").val(<%=f_ccc_catalogid%>);
		$.ajax({
			url:"../multirate/select_viewindex.do",
			data:'f_ccc_catalogid=<%=f_ccc_catalogid%>&f_ccc_contentid=<%=f_ccc_contentid%>',
			success:function(data) {
				data = JSON.parse(data);
				$("#f_ccc_viewindex").val(data.f_ccc_viewindex);
				$("#f_ccc_onlinedate").val(data.f_ccc_onlinedate);
				$("#f_ccc_offlinedate").val(data.f_ccc_offlinedate);
				beforeData(data, <%=f_ccc_contentid%>, "", "../beforeData.do");
				$.ajax({
					url:"../statistics/area_tree.do?f_sa_id=0",
					success:function(json) {
						json = JSON.parse(json);
						var str = "";
						if(data.f_catalogmultirate_areacode==0){
							for(var i=0;i<json.length;i++) {
								str += '<input type="checkbox" checked="checked" name="f_catalogmultirate_areacode" value="'+json[i].pId+'">'+json[i].name+" ";
							}
						}else if(data.f_catalogmultirate_areacode.indexOf(',')==-1){
							for(var i=0;i<json.length;i++) {
								if(data.f_catalogmultirate_areacode==json[i].pId){
									str += '<input type="checkbox" checked="checked" name="f_catalogmultirate_areacode" value="'+json[i].pId+'">'+json[i].name+" ";
								}else{
									str += '<input type="checkbox" name="f_catalogmultirate_areacode" value="'+json[i].pId+'">'+json[i].name+" ";
								}
							}
						}else{
							var arr = data.f_catalogmultirate_areacode.split(',');
							for(var i=0;i<json.length;i++) {
								if(arr.indexOf(json[i].pId)>=0){
									str += '<input type="checkbox" checked="checked" name="f_catalogmultirate_areacode" value="'+json[i].pId+'">'+json[i].name+" ";
								}else{
									str += '<input type="checkbox" name="f_catalogmultirate_areacode" value="'+json[i].pId+'">'+json[i].name+" ";
								}
							}
						}
						str += '<input type="checkbox" name="all" onclick="change()">全选'+" ";
						document.getElementById('area').innerHTML=str;
					}
				});
			}
		});
	
		
		$("#contentForm").validate({
			rules: {
				f_ccc_viewindex: {
					required: true,
					range:[0,1000000000]
				}
			},
			messages: {
				f_ccc_viewindex: {
					required: "请输入排序值",
					range:"输入值必须在0-1000000000"
				}
			},
			
		});
	});

	function change(){
		var value = document.getElementsByName('all');
		var val = document.getElementsByName('f_catalogmultirate_areacode');
		if(value[0].checked){
			for(var i=0;i<val.length;i++){
				val[i].checked="true";
			}
		}else{
			for(var i=0;i<val.length;i++){
				val[i].checked=!val[i].checked;
			}
		}
	}
	
	function _submitFm() {
		var val=document.getElementsByName('f_catalogmultirate_areacode');
		var str="";
		var j=0;
		for(var i=0;i<val.length;i++){
			if(val[i].checked){
				str+=","+val[i].value;
				j++;
			}
		}
		str = str.substring(1);
		if(j==i){
			str=0;
		}
		if($("#contentForm").validate().form()) {
		app_ajax('../multirate/update_viewindex.do?f_catalogmultirate_areacode='+str, $("#contentForm").serialize(), function(data) {
				if (data.success) {
					$.messager.progress('close');
					$.messager.alert('提示', '提交成功！', 'info', function() {
						parent.$('#dlg').dialog('close');
						parent.gotoSearch($('#easyui-treegrid'));
					});
				} else {
					$.messager.alert('提示', data.result, 'info', function() {
						$.messager.progress('close');
					});
				}
		});
	  }
	}
</script>
</head>

<body class="overfwidth">
	<div class="barnavtop">您所在的位置：包绑定管理 &gt; 修改</div>
	<div id="workspace">
		<!--主体 开始-->
		<div id="container">
			<div class="editspace">
				<form id="contentForm" class="cmxform" enctype="multipart/form-data" name="formName">
					<input type="hidden" id="f_ccc_catalogid" name="f_ccc_catalogid" value="" />
					<input type="hidden" id="f_ccc_contentid" name="f_ccc_contentid" value="" />
					<input type="hidden" name="stime" value="<%=nonceObj[0]%>"/>
					<input type="hidden" name="sign" value="<%=nonceObj[1]%>"/>
					<legend>修改</legend>
					<fieldset>
						<div class="fitem">
							<table width="100%" border="0" cellpadding="0" cellspacing="0">
								<tr>
									<td width="30%" align="right">
										<span class="red">*</span>排序值:
									</td>
									<td>
										<input id="f_ccc_viewindex" name="f_ccc_viewindex" style="width: 150px;" value="" class="yl_inp yw_name" />
										<span id="f_ccc_viewindex_tip" class="tip">
									</td>
								</tr>
							</table>
						</div>
					</fieldset>
					
					<fieldset>
						<div class="fitem">
						<table width="100%" border="0" cellpadding="0" cellspacing="0">
							<tr>
							<td style="color:red;">
								默认"上线时间"为您当前绑定时间的后五分钟,默认"下线时间"为:2099-12-31 23:59:59
							</td>
							</tr>
						</table>
						</div>
					</fieldset>
					
					<fieldset>
						<div class="fitem">
							<table width="100%" border="0" cellpadding="0" cellspacing="0">
								<tr>
									<td width="30%" align="right">
										<span class="red">*</span>上线时间:
									</td>
									<td>
										<input id="f_ccc_onlinedate" name="f_ccc_onlinedate" type="text" onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" style="width: 150px;" value="" class="yl_inp yw_name" />	
									</td>
								</tr>
							</table>
						</div>
					</fieldset>

					<fieldset>
						<div class="fitem">
							<table width="100%" border="0" cellpadding="0" cellspacing="0">
								<tr>
									<td width="30%" align="right">
										<span class="red">*</span>下线时间:
									</td>
									<td>
										<input id="f_ccc_offlinedate" name="f_ccc_offlinedate" type="text" onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" style="width: 150px;" value="" class="yl_inp yw_name" />	
									</td>
								</tr>
							</table>
						</div>
					</fieldset>
				</form>
				<fieldset>
						<div class="fitem">
							<table width="100%" border="0" cellpadding="0" cellspacing="0">
								<tr>
									<td width="30%" align="right">
										<span class="red">*</span>地区选择:
									</td>
									<td id="area">
									</td>
								</tr>
							</table>
						</div>
					</fieldset>
			</div>
			<div class="toolbar" style="text-align: center;">
				<a class="easyui-linkbutton" data-options="iconCls:'icon-ok'"
					href="javascript:void(0);" onclick="_submitFm()">保存</a> <a
					href="javascript:void(0);" data-options="iconCls:'icon-cancel'"
					class="easyui-linkbutton"
					onclick="javascript:parent.$('#dlg').dialog('close')">取消</a>
			</div>
		</div>
		<!--主体 结束-->
	</div>
</html>
